#include <iostream>
#include <algorithm>
using namespace std;

const int N=1000;
int arr1[N]= {0};

int main_5()
{
    int n,cnt=0;
    cin>>n;
    for (int i=0;i<n ;i++ )
    {
        cin>>arr1[i];
    }
    sort(arr1,arr1+n);
    for (int i=0;i<n ;i++ )
    {
        if (arr1[i]-arr1[i+1]==-1)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}
